package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.domain.TemplateFile;
import com.ruoyi.business.domain.bo.TemplateFileBo;
import com.ruoyi.business.domain.vo.TemplateFileVo;
import com.ruoyi.business.mapper.TemplateFileMapper;
import com.ruoyi.business.service.ITemplateFileService;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

/**
 * @author 最爱喝兽奶
 * @create 2022/9/7
 **/
@Service
public class TemplateFileServiceImpl extends ServiceImpl<TemplateFileMapper, TemplateFile> implements ITemplateFileService {


    @Override
    public TableDataInfo<TemplateFileVo> queryListByPage(TemplateFileBo bo) {
        Page<TemplateFileVo> page = baseMapper.queryListByPage(PageUtils.buildPage(bo), bo);
        return PageUtils.buildTableDataInfo(page);
    }

    @Override
    public void insertTemplateFile(TemplateFileBo bo) {
        TemplateFile templateFile = new TemplateFile();
        BeanUtils.copyBeanProp(templateFile, bo, true);
        baseMapper.insert(templateFile);
    }

    @Override
    public void updateTemplateFile(TemplateFileBo bo) {
        TemplateFile templateFile = new TemplateFile();
        BeanUtils.copyBeanProp(templateFile, bo, true);
        baseMapper.updateById(templateFile);
    }

    @Override
    public void deleteTemplateFile(String id) {
        baseMapper.deleteById(id);
    }

    @Override
    public TemplateFileVo getTemplateFile(String id) {
        TemplateFile templateFile = baseMapper.selectById(id);
        TemplateFileVo vo = new TemplateFileVo();
        BeanUtils.copyBeanProp(vo, templateFile, true);
        return vo;
    }
}
